import { useEffect, useState } from "react";
import "./App.css";

function App() {
   const [count, setCount] = useState(0)

   useEffect(() => {
     setInterval(() => {
        // 打印正常，setCount的函数写法会确保每次拿到最新的count
        setCount(count => count + 1)
     }, 1000)
   }, [])

   return <>
    <div>{count}</div>
   </>
}

export default App;
